import { Api } from '../api'

export interface AppInfo {
  name: string
  descriotion: string
}

export interface UserInfo {
  defaultTenant: string
  unionId: string
  updateTime: string
  avatar: string
  label: string
  password: string
  defaultTenantName: string
  deleted: boolean
  platId: string
  captcha: string
  createTime: string
  phone: string
  name: string
  id: string
  plat: string
  email: string
  username: string
}

export interface MenuItem {
  id: string
  parentId: string
  disabled?: boolean
  title: string
  key: string
  expanded?: boolean
  isLeaf?: boolean
  children?: MenuItem[]
  text: string
  i18n?: string
  group?: boolean
  link: string
  linkExact?: boolean
  externalLink?: string
  target?: '_blank' | '_self' | '_parent'
  iconId?: string
  badge?: number
  badgeDot?: boolean
  badgeStatus?: string
  hide: boolean
  hideInBreadcrumb: boolean
  acl?: string[]
  shortcut?: boolean
  shortcutRoot?: boolean
  reuse?: boolean
  open?: boolean
  icon?: IconInfo
  permissionList?: string[]
}

export interface IconInfo {
  id?: string
  deleted?: boolean
  type?: string
  value: string
  theme: string
  spin?: boolean
  twoToneColor?: string
  iconfont?: string
}

export type MenuInfo = MenuItem[]

export interface CurrentInfo {
  app: AppInfo
  user: UserInfo
  menu: MenuInfo
}

export interface TenantInfo {
  id?: string
  name?: string
  deleted?: true | false
}

export type TenantList = TenantInfo[]

export function current() {
  return useGet<CurrentInfo>(Api.CurrentApi, null)
}

export function joinedTenantList() {
  return useGet<TenantList>(`${Api.BaseSysTenantApi}/user/tenant`)
}
